/*
 * @Author: dongxueting
 * @Date: 2023-05-18 13:30:42
 * @LastEditTime: 2023-10-26 14:11:07
 * @email: dong_xt@reachauto.com
 * @Description: 
 */
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
const store = new Vuex.Store({
    state: {
        themeMode: "dark",
        lastValue: {},
        signals: []
    },
    getters: {
        last: state => {
            return Object.keys(state.lastValue).map(v => state.lastValue[v]).flat()
        }
    },
    mutations: {
        change (state, payload) {
            state.themeMode = payload
        },
        addGraphSignal (state, payload) {
            const { key, data } = payload
            const value = Object.keys(data).filter(v => v !== 'rowkey' && v !== 'sendingtime').map(key => ({
                key,
                value: data[key]
            }))
            state.lastValue = {
                ...state.lastValue,
                [key]: value
            }
        },
        initSignal(state, payload) {
            state.signals = payload
        }
    }
})
export default store;
